<?php
/**
 * Created by PhpStorm.
 * User: nango
 * Date: 2018/1/3
 * Time: 17:23
 */

namespace app\common\model;

use think\Model;

class Image extends Model
{
    protected $pk = 'id';

    const FLAG_DEFAULT = 0;
    const FLAG_TOP1 = 1;
    const FLAG_TOP = 9;

    static $flag_desc = [
        self::FLAG_DEFAULT => '默认',
        self::FLAG_TOP1 => '置顶',
        self::FLAG_TOP => '置顶'
    ];
    /**
     * 自动完成数据
     * @var array
     */
    protected $auto = [];

    public function category() {
        return $this->belongsTo('Category','cid');
    }

    public function setPublishtimeAttr($value)
    {
        return $value ? strtotime($value) : time();
    }
}